#ifndef ASIO_BOX_CONNECTION_IMPL_H_INCLUDED
#define ASIO_BOX_CONNECTION_IMPL_H_INCLUDED

#include <Core/BoxApi/IBoxConnection.hpp>

#include <boost/asio.hpp>
#include <boost/shared_ptr.hpp>

namespace Core { namespace BoxApi {

namespace Aux {

/**
 *
 */
boost::shared_ptr<boost::asio::io_service> getSharedIOService();

} // namespace Aux

/**
 *
 */
class AsioBoxConnectionImpl public IBoxConnection {
public :
	explicit AsioBoxConnectionImpl(BoxConnectionParams const & params);
	~AsioBoxConnectionImpl() throw ();

	virtual void establishConnection() throw (std::exception);
	virtual void close() throw ();
	
	virtual int getConnectionId() const throw (std::exception);
	virtual IMessagePtr sendMessageSync(IMessagePtr message);

private :
	BoxConnectionParams const m_params;
	boost::asio::ip::tcp::socket m_socket;

};

typedef boost::shared_ptr<AsioBoxConnectionImpl> AsioBoxConnectionImplPtr;

} } // namespace Core, BoxApi

#endif

